/**
 * 通用混合
 * */
import {mapState} from "vuex";
import _ from "lodash";

export default {
   data(){
       return {
           deviceStatus:[
               {value:'NORMAL',color:'#008aff',name:'运行',code:1},
               {value:'ABNORMAL',color:'#ff0000',name:'告警',code:2},
               // {value:'FAULT',color:'#fae600',name:'故障',code:3},
               {value:'OFFLINE',color:'#f09614',name:'离线',code:4},
               // {value:'UNBORN',color:'#f09614',name:'非正常',code:5},
           ],
           dateType: 1,
           defaultListData:{//当左侧栏筛选
               code:0,
               size: 10,
               total:0,
               records:[],
               current:1,
           },
       }
   },
   computed:{
       ...mapState('admin/base',['orgIds']),
       ...mapState('admin/websoket',['websoketData']),
       status:function (){
           return this.deviceStatus.find(o=>o.code==_.get(this.pointData,'0.deviceStatus'))||this.deviceStatus[0];
       }
   },
    watch:{
       orgIds:function (newData,oldData){
          if(newData!=oldData){
              this.getData();
          }
      },
      websoketData:{
          handler(newData,oldData){
               if(newData!=oldData){
                   this.getData();
               }
           },
          deep:true
      }
   },
    methods: {

        getData(){},
        getStutas(item){
            return this.deviceStatus.find(o=>o.code==_.get(item,'deviceStatus'))||this.deviceStatus[0];
        },
        changeTimeType(value){
            this.dateType=value;
            this.getData();
        }
    }
}
